onLoad(options) {
  const code = options.code || '';
  const state = options.state || '';
  
  if (code) {
    authApi.wxCallback(code, state).then(res => {
      if (res.data.success) {
        uni.setStorageSync('token', res.data.token);
        uni.setStorageSync('userInfo', res.data.user);
        uni.reLaunch({
          url: '/pages/index/index'
        });
      } else {
        uni.showToast({
          title: res.data.message || '微信登录失败',
          icon: 'none'
        });
        setTimeout(() => {
          uni.reLaunch({
            url: '/pages/auth/login'
          });
        }, 2000);
      }
    }).catch(err => {
      uni.showToast({
        title: '微信登录失败',
        icon: 'none'
      });
      setTimeout(() => {
        uni.reLaunch({
          url: '/pages/auth/login'
        });
      }, 2000);
    });
  }
} 